<template>
	<view class="home-container">
		<h-card padding="25rpx 20rpx 0rpx" margin="0" br="0">
			<u-swiper :height="300" :list="imgList" :title="false" indicator indicatorMode="dot" radius="20" @click="imgListClick"/>
		</h-card>
		<!---->
		<h-card title="维保" padding="10rpx 25rpx 25rpx" br="0" margin="0">
			<div class="maintenance-container pt10r">
				<div class="function" @click="handleTo('/pages_sub1/maintenance/list/index',{maintenanceProcessStatus:'0'})">
					<img src="@/pages_sub1/static/image/home/noGetOrder.png"/>
					<div class="name">未接单 {{wbNum.wjd || '0'}}</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/maintenance/list/index',{maintenanceProcessStatus:'2345'})">
					<img src="@/pages_sub1/static/image/home/ing.png"/>
					<div class="name">进行中 {{wbNum.jxz || '0'}}</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/maintenance/list/index',{maintenanceProcessStatus:'8'})">
					<img src="@/pages_sub1/static/image/home/outTimeIng.png"/>
					<div class="name">即将超期 {{wbNum.jjcq || '0'}}</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/maintenance/list/index',{maintenanceProcessStatus:'9'})">
					<img src="@/pages_sub1/static/image/home/outTimeUnfinish.png"/>
					<div class="name">超期未完成 {{wbNum.cqwwc || '0'}}</div>
				</div>
			</div>
		</h-card>
		<!---->
		<h-card title="维修" margin="25rpx 0 0" padding="10rpx 25rpx 25rpx" br="0">
			<div class="repair-container flex-x-between">
				<div class="need-to-repair" @click="handleTo('/pages_sub1/repair/list/index',{status:'0'})">
					<image src="@/pages_sub1/static/image/home/needToRepair.png"></image>
					<div class="name1">未接单 {{wxNum.wjd||'0'}}</div>
					<div class="toSee-container flex-x-start-center">
						<div class="name2">去查看</div>
						<div class="circle flex-x-center-center">
							<image src="@/static/image/common/lg-w.png"></image>
						</div>
					</div>
				</div>
				<div class="flex-y-between">
					<div class="has-get-order" @click="handleTo('/pages_sub1/repair/list/index',{status:'1'})">
						<image src="@/pages_sub1/static/image/home/hasGetOrder.png"></image>
						<div class="name1">已接单 {{wxNum.yjd||'0'}}</div>
						<div class="name2">去查看</div>
					</div>
					<div class="on-going" @click="handleTo('/pages_sub1/repair/list/index',{status:'23'})">
						<image src="@/pages_sub1/static/image/home/ingBg.png"></image>
						<div class="name1">进行中 {{wxNum.jxz||'0'}}</div>
						<div class="name2">去查看</div>
					</div>
				</div>
			</div>
		</h-card>
		<!---->
		<h-card title="其他" margin="25rpx 0 0" padding="15rpx 25rpx 25rpx" br="0">
			<div class="other-container">
				<div class="function" @click="handleTo('/pages_sub1/other/lift/index',{})">
					<img src="@/pages_sub1/static/image/home/liftInfo.png"/>
					<div class="name">电梯档案</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/other/team/index',{})">
					<img src="@/pages_sub1/static/image/home/team.png"/>
					<div class="name">小组团队</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/user/index',{})">
					<img src="@/pages_sub1/static/image/home/me.png"/>
					<div class="name">我的信息</div>
				</div>
				<div class="function" @click="handleTo('/pages_sub1/specialCheck/activityList/index',{})">
					<img src="@/pages_sub1/static/image/home/specialCheck.png"/>
					<div class="name">专项检查</div>
				</div>
			</div>
		</h-card>
		<!-- <h-tarbar></h-tarbar> -->
	</view>
</template>

<script>
import setting from './setting'
import { getRepairOrderStatusCount, getMaintenanceOrderStatusCount} from "@/api"

    export default {
        data() {
			return {
			    setting: setting,
			    //轮播图
                imgList: setting.imgs,
				//维保单据各状态数量
				wbNum:{
                    wjd: 0,
                    yjd: 0,
                    jxz: 0,
				},
                //维修单据各状态数量
                wxNum:{
                    wjd: 0,
                    jxz: 0,
                    jjcq: 0,
					cqwwc: 0,
                },

			}
		},
		onLoad() {
			let _ = this
		},
        onShow(){
            let _ = this
            // #ifdef MP
            wx.hideHomeButton()
            // #endif
            _.getRepairOrderStatusCount()
			_.getMaintenanceOrderStatusCount()
        },
        onShareAppMessage() { // 分享到微信好友
			// 更多参数配置，参考文档
            return {
                title: '维保小程序',
                path: '/pages/login/index',
                imageUrl: 'http://wxb1997.oss-cn-beijing.aliyuncs.com/img/lift.png',
            }
        },
        onShareTimeline() { // 分享到朋友圈
            return {
                title: '维保小程序',
                path: '/pages/login/index',
                imageUrl: 'http://wxb1997.oss-cn-beijing.aliyuncs.com/img/lift.png',
            }
        },
		methods: {
            //维修单状态统计
            async getMaintenanceOrderStatusCount(){
                let _ = this
                const { data: res } = await getMaintenanceOrderStatusCount()
                _.wbNum.wjd = res.data.filter(v=>{return v.status=='0'})[0].count||"0"
                _.wbNum.jxz = res.data.filter(v=>{return v.status=='1'})[0].count||"0"
                _.wbNum.jjcq = res.data.filter(v=>{return v.status=='2'})[0].count||"0"
                _.wbNum.cqwwc = res.data.filter(v=>{return v.status=='3'})[0].count||"0"
            },

            //维修单状态统计
            async getRepairOrderStatusCount(){
                let _ = this
                const { data: res } = await getRepairOrderStatusCount()
                _.wxNum.wjd = res.data.filter(v=>{return v.status=='0'})[0].count||"0"
                _.wxNum.yjd = res.data.filter(v=>{return v.status=='1'})[0].count||"0"
                _.wxNum.jxz = res.data.filter(v=>{return v.status=='2'})[0].count||"0"
			},

            imgListClick(){

			},
			handleTo(url, params) {
                let _ = this
                uni.$u.route( url, params )
			},
		}
	}
</script>

<style lang="scss" scope>
@import 'index';
</style>

